<template>
  <div>{{ hiddenPhoneNumber }}</div>
</template>
<script setup>
let props = defineProps(["number"]);
// console.log(props.number);
let hiddenPhoneNumber = hidePhoneNumber(props.number);
// console.log(hiddenPhoneNumber);
function hidePhoneNumber(phoneNumber) {
  const length = phoneNumber.length;
  const visibleDigits = 1; // 首尾保留的可见数字个数

  if (length) {
    const startIndex = visibleDigits;
    const hiddenStr = "*".repeat(4);
    return (
      phoneNumber.substring(0, startIndex) +
      hiddenStr +
      phoneNumber.substring(length - 1)
    );
  } else {
    return phoneNumber;
  }
}
</script>
<style scoped>
</style>